import math

n = int(input())
nums = [[] for _ in range(n)]
for k in range(n):
    m = int(input())
    for _ in range(m):
        nums[k].append(list(map(int, input().split())))
number = [0] * n
for i in range(n):
    ans = 1
    for j in nums[i]:
        ans *= pow(*j)
    number[i] = ans
sets = set()
for i in range(n):
    ans = 1
    for j in range(n):
        if i == j: continue
        ans = ans // math.gcd(ans, number[j]) * number[j]
    sets.add(ans)
print(len(sets))
